﻿using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;

namespace LJSheng.Data
{
    public class EFDB : DbContext
    {
        /// <summary>
        /// EF对象
        /// </summary>
        public EFDB(): base("name=MSSQL")
        {
            //模型更改时重新创建数据库
            //Database.SetInitializer<EFDB>(new DropCreateDatabaseIfModelChanges<EFDB>());
            //数据库不存在时重新创建数据库,存在的话会报错
            Database.SetInitializer<EFDB>(new CreateDatabaseIfNotExists<EFDB>());
            //每次启动应用程序时创建数据库
            //Database.SetInitializer<EFDB>(new DropCreateDatabaseAlways<EFDB>());
            //从不创建数据库
            //Database.SetInitializer<EFDB>(null);
        }

        /// <summary>
        /// 禁止创建表的时候表名复数
        /// </summary>
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        }

        public DbSet<LJSheng> LJSheng { get; set; }
        public DbSet<LUser> LUser { get; set; }
        public DbSet<CPFL> CPFL { get; set; }
        public DbSet<ShopList> ShopList { get; set; }
        public DbSet<LOrder> LOrder { get; set; }
        public DbSet<PL> PL { get; set; }
        public DbSet<Pay> Pay { get; set; }
        public DbSet<Zan> Zan { get; set; }
        public DbSet<OpenCity> OpenCity { get; set; }
        public DbSet<SMS> SMS { get; set; }
        public DbSet<wxgjz> wxgjz { get; set; }
        public DbSet<xinwen> xinwen { get; set; }
        public DbSet<spicture> spicture { get; set; }
        public DbSet<zhekou> zhekou { get; set; }
        public DbSet<pllist> pllist { get; set; }
        public DbSet<TC> TC { get; set; }
    }
}
